package com.ang.jwt;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.ang.jwt.util.JwtUtil2;
import com.ang.jwt.util.JwtUtils;
import io.jsonwebtoken.Claims;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

public class Test {

    public static void main(String[] args) throws Exception {
//        test01();
        test02();
    }

    public static void test02() throws Exception{
        //小明失效 10s
        String sc = JwtUtil2.createJwtToken("小明",5*1000L,"1",null);

        Thread.sleep(5000);
        System.out.println(JwtUtil2.parseJWT(sc));
    }

    public static void test01(){
        //小明失效 10s
        String sc = JwtUtils.createJWT("1","小明", 30000);
        System.out.println(sc);
        System.out.println(JwtUtils.validateJWT(sc).getErrCode());
        System.out.println(JwtUtils.validateJWT(sc).getClaims().getId());
        //Thread.sleep(3000);
        System.out.println(JwtUtils.validateJWT(sc).getClaims());
    }
}
